<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
    xmlns:jsf="http://xmlns.jcp.org/jsf"
    xmlns:pt="http://java.sun.com/jsf/passthrough"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs">
    <o:importFunctions type="java.lang.Math" />
    <p:remoteCommand name="refreshPaginator" action="#{DatasetPage.refreshPaginator()}" process="@this" update="@form" />
    
    <ui:param name="hasFileMetadata" value="#{!empty DatasetPage.workingVersion.fileMetadatas}" />
    <ui:param name="fileMetadataCount" value="#{DatasetPage.workingVersion.fileMetadatas.size()}" />
    <ui:param name="lockedFromEdits" value="#{DatasetPage.lockedFromEdits}" />
    <ui:param name="hasValidTermsOfAccess" value="#{DatasetPage.hasValidTermsOfAccess}" />
    <ui:param name="uploadButtonDisabled" value="#{lockedFromEdits or !hasValidTermsOfAccess ? 'disabled' : ''}" />
    <ui:param name="canUpdateAndAuthenticated" value="#{DatasetPage.sessionUserAuthenticated and DatasetPage.canUpdateDataset() and !widgetWrapper.widgetView}" />

    <ui:remove>
    <!--
    This fragment is included only on the dataset pg, empty editMode render logic
    -->            
    </ui:remove>

    <!-- Toggle Files Display Components -->
    <div jsf:id="filesDisplayToggleBlock" jsf:rendered="#{DatasetPage.fileTreeViewRequired}" class="row">
        <div class="form-group col-xs-12">
            <label class="col-xs-2 control-label" style="padding:.3em 1em;">
                #{bundle['file.display.label']}
            </label>
            <div class="col-xs-4 input-group">
                <p:selectOneButton id="displayValue" styleClass="form-control" value="#{DatasetPage.fileDisplayMode}" 
                                   style="padding:0;border:0;box-shadow:none;">
                    <f:selectItem itemLabel="#{bundle['file.display.table']}" itemValue="Table" />
                    <f:selectItem itemLabel="#{bundle['file.display.tree']}" itemValue="Tree" />

                    <!-- AJAX UPDATES TO TOGGLE p:dataTable widgetVar="filesTable" AND p:tree widgetVar="filesTree" COMPONENTS BELOW -->
                    <p:ajax update=":datasetForm" process="@this"/> 
                </p:selectOneButton>
            </div>
        </div>
    </div>

    <p:remoteCommand name="rebindCommand" process="@this" update="filesTable"/>

    <!-- Files Table -->
    <!-- TABLESTYLE + WIDTH:AUTO FIX COL WIDTH OVERFLOW HIDDEN, MIN-WIDTH 100% ADDED FOR TABLE CONTENT LESS THAN 100% https://stackoverflow.com/a/38582318 -->
    <ui:remove>
        <!--TODO - consider moving the validateFilesOutcome param here/ other refactoring to simplify managing selection state - see issue #8180/PR #8182 -->
    </ui:remove>
    <p:dataTable id="filesTable" 
                 rows="10" paginator="#{DatasetPage.fileMetadatasSearch.size() gt 10}" paginatorPosition="bottom"
                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} #{bundle['file.dynamicCounter.filesPerPage']} {RowsPerPageDropdown}"
                 rowsPerPageTemplate="10,25,50"
                 style="margin-right:1px;" tableStyle="min-width:100%;width:auto;"
                 value="#{DatasetPage.fileMetadatasSearch}"
                 rowIndexVar="rowNum" rowKey="#{fileMetadata.dataFile.storageIdentifier}"
                 rowSelectMode="checkbox" selection="#{DatasetPage.selectedFiles}" var="fileMetadata" widgetVar="filesTable"
                 rendered="#{DatasetPage.fileDisplayTable and (DatasetPage.workingVersion != null)}"
                 emptyMessage="#{fileMetadataCount == 0 ? bundle['file.notFound.tip'] : bundle['file.notFound.search']}"
                 ariaRowLabel="#{bundle['file.select.action']} #{fileMetadata.label}">
        <p:ajax event="page" listener="#{DatasetPage.fileListingPaginatorListener}" update="filesTable" process="@this"  oncomplete="refreshPaginator(),rebindCommand()"  immediate="true"/>
        <p:ajax event="toggleSelect" listener="#{DatasetPage.toggleAllSelected()}" update="@form:validateFilesOutcome, filesTable"  process="@this" oncomplete="rebindCommand()"  /> 
        <p:ajax event="rowUnselectCheckbox" listener="#{DatasetPage.setSelectAllFiles(false)}" update="@form:validateFilesOutcome, filesTable" process="@this" oncomplete="rebindCommand()"  />
        <p:ajax event="rowSelect" listener="#{DatasetPage.setSelectAllFiles(false)}" update="@form:validateFilesOutcome, filesTable" process="@this" oncomplete="rebindCommand()" />
        <p:ajax event="rowSelectCheckbox" listener="#{DatasetPage.setSelectAllFiles(false)}" update="@form:validateFilesOutcome, filesTable" process="@this" oncomplete="rebindCommand()"  />
        <p:ajax event="rowUnselect" listener="#{DatasetPage.setSelectAllFiles(false)}" update="@form:validateFilesOutcome, filesTable" process="@this" oncomplete="rebindCommand()" />
        <p:ajax event="rowDblselect" listener="#{DatasetPage.setSelectAllFiles(false)}" update="@form:validateFilesOutcome, filesTable" process="@this" oncomplete="rebindCommand()" />

        <f:facet name="header">
            <div class="row form-inline" jsf:id="cloudStorageBlock" jsf:rendered="#{DatasetPage.showComputeButton()}">
                <!-- Cloud Storage Access -->
                <div class="form-group col-xs-12 text-left">
                    <div class="col-xs-12">
                        <p class="help-block">
                            <h:outputFormat value="#{bundle['file.cloudStorageAccess.help']}" escape="false">
                                <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                <f:param value="#{systemConfig.guidesVersion}"/>
                                <f:param value="#{DatasetPage.cloudEnvironmentName}"/>
                            </h:outputFormat>
                        </p>
                    </div>
                    <label class="col-sm-3 control-label">
                        #{bundle['file.cloudStorageAccess']}
                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                              data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['file.cloudStorageAccess.tip']}"></span>
                    </label>
                    <div class="col-md-4 col-sm-5 col-xs-6 input-group">
                        <div id="copy-input" class="form-control">#{DatasetPage.swiftContainerName}</div>
                        <span class="input-group-btn">
                            <button class="btn btn-default btn-copy" type="button" id="copy-button" data-clipboard-action="copy" data-clipboard-target="#copy-input">
                                <span class="glyphicon glyphicon-copy"></span> #{bundle['file.copy']}
                            </button>
                        </span>
                    </div>
                </div>
            </div>
            <div jsf:id="filesHeaderBlock" class="row">
                <div class="col-xs-5">
                    <!-- FILE SEARCH -->
                    <div class="input-group" jsf:rendered="#{fileMetadataCount gt 1}">
                        <label id="searchLabel" class="sr-only" jsf:for="searchFiles">#{bundle.search}</label>
                        <p:inputText id="searchFiles" title="#{bundle.search}" styleClass="form-control" value="#{DatasetPage.fileLabelSearchTerm}" widgetVar="inputSearchTerm"
                                     onkeypress="if (event.keyCode == 13) {
                                                 submitsearch();
                                                 return false;
                                             }">
                            <f:passThroughAttribute name="aria-labelledby" value="searchLabel"/>
                        </p:inputText>
                        <p:watermark for="searchFiles" value="#{bundle['file.search.placeholder']}"/>
                        <p:remoteCommand name="submitsearch" action="#{DatasetPage.updateFileSearch()}" process="@this @widgetVar(inputSearchTerm)" update="@form" partialSubmit="true"/>

                        <span class="input-group-btn">
                            <p:commandLink title="#{bundle['dataverse.search.btn.find']}" styleClass="btn btn-default bootstrap-button-tooltip" action="#{DatasetPage.updateFileSearch()}" process="@this @widgetVar(inputSearchTerm)" update="@form" partialSubmit="true"  ariaLabel="#{bundle['dataverse.search.btn.find']}">
                                <span class="glyphicon glyphicon-search no-text"/>
                            </p:commandLink>
                        </span>
                    </div>
                </div>
                <div class="col-xs-7 text-right">
                    <p:outputPanel id="filesButtons" class="button-block no-margin-top"
                                    rendered="#{canUpdateAndAuthenticated}">
                        <!-- DOWNLOAD DCM SCRIPT BUTTON -->
                        <h:commandLink id="rsyncDLFF" actionListener="#{DatasetPage.downloadRsyncScript()}" styleClass="btn btn-default"
                                       rendered="#{  hasFileMetadata and DatasetPage.lockedDueToDcmUpload}">
                            <span class="glyphicon glyphicon-download-alt"/> <h:outputText value=" #{bundle['file.rsyncUpload.step2.downloadScriptButton']}"/>
                        </h:commandLink>
                        <!-- UPLOAD FILES BUTTON -->
                        <h:outputLink value="/editdatafiles.xhtml?datasetId=#{DatasetPage.dataset.id}&#38;mode=UPLOAD"
                                      type="button" styleClass="btn btn-default btn-access #{uploadButtonDisabled}"
                                      disabled="#{lockedFromEdits}">
                            <span class="glyphicon glyphicon-plus"/> <h:outputText id="uploadFile-s-Link" value="#{bundle['file.uploadFiles']}"/>
                        </h:outputLink>
                    </p:outputPanel>
                </div>
            </div>

            <!-- FILES FILTER FACETS -->
            <div class="row" style="margin-bottom:10px;" jsf:rendered="#{(fileMetadataCount gt 1)}">
                <div class="col-xs-7 text-left" jsf:rendered="#{DatasetPage.indexedVersion}">
                    <div class="text-muted small" style="font-weight:normal;" jsf:rendered="#{(DatasetPage.fileMetadatasSearch.size() gt 0)}">#{bundle['file.results.filter']}</div>
                    <!-- FACET: TYPE -->
                    <div class="btn-group" style="margin-right:20px;" jsf:rendered="#{!(empty DatasetPage.fileTypeFacetLabels)}">
                        <button type="button" class="btn btn-link dropdown-toggle" style="padding:0;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            #{bundle['file.results.filter.type']} <h:outputText value="#{(empty DatasetPage.fileTypeFacet) ? bundle['file.results.filter.all'] : DatasetPage.fileTypeFacet}"
                                          styleClass="#{!empty DatasetPage.fileTypeFacet ? 'highlightBold' : ''}"/> <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <!-- link for "All" - all file types: -->
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{empty DatasetPage.fileTypeFacet ? 'highlightBold' : ''}" value="#{bundle['file.results.filter.all']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                                    <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                    <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                    <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                </h:outputLink></li>
                            <li role="separator" class="divider"></li>
                            <ui:repeat value="#{DatasetPage.fileTypeFacetLabels}" var="facetLabel">
                                <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                        <h:outputFormat styleClass="#{facetLabel.name == DatasetPage.fileTypeFacet ? 'highlightBold' : ''}" value="#{facetLabel.name} &#40;{0}&#41;">
                                            <f:param value="#{facetLabel.count}"/>
                                        </h:outputFormat>
                                        <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                        <f:param name="version" value="#{DatasetPage.version}"/>
                                        <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                        <f:param name="fileTypeGroupFacet" value='"#{facetLabel.name}"'/>
                                        <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                        <f:param name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                                        <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                        <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                        <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                        <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                    </h:outputLink></li>
                            </ui:repeat>
                        </ul>
                    </div>

                    <!-- FACET: ACCESS -->
                    <div class="btn-group" style="margin-right:20px;" jsf:rendered="#{!(empty DatasetPage.fileAccessFacetLabels)}">
                        <button type="button" class="btn btn-link dropdown-toggle" style="padding:0;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            #{bundle['file.results.filter.access']} <h:outputText value="#{(empty DatasetPage.fileAccessFacet) ? bundle['file.results.filter.all'] : DatasetPage.fileAccessFacet}"
                                          styleClass="#{!empty DatasetPage.fileAccessFacet ? 'highlightBold' : ''}"/> <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <!-- link for "All" - i.e., all (both) types of access: -->
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{empty DatasetPage.fileAccessFacet ? 'highlightBold' : ''}" value="#{bundle['file.results.filter.all']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                                    <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                    <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                    <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                </h:outputLink></li>
                            <li role="separator" class="divider"></li>
                            <ui:repeat value="#{DatasetPage.fileAccessFacetLabels}" var="facetLabel">
                                <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                        <h:outputFormat styleClass="#{facetLabel.name == DatasetPage.fileAccessFacet ? 'highlightBold' : ''}" value="#{facetLabel.name} &#40;{0}&#41;">
                                            <f:param value="#{facetLabel.count}"/>
                                        </h:outputFormat>
                                        <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                        <f:param name="version" value="#{DatasetPage.version}"/>
                                        <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                        <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                        <f:param name="fileAccess" value="#{facetLabel.name}"/>
                                        <f:param name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                                        <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                        <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                        <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                        <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                    </h:outputLink></li>
                            </ui:repeat>
                        </ul>
                    </div>

                    <!-- FACET: TAG -->
                    <div class="btn-group" style="margin-right:20px;" jsf:rendered="#{!(empty DatasetPage.fileTagsFacetLabels)}">
                        <button type="button" class="btn btn-link dropdown-toggle" style="padding:0;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            #{bundle['file.results.filter.tag']} <h:outputText value="#{(empty DatasetPage.fileTagsFacet) ? bundle['file.results.filter.all'] : DatasetPage.fileTagsFacet}"
                                          styleClass="#{!empty DatasetPage.fileTagsFacet ? 'highlightBold' : ''}"/> <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <!-- link for "All" - i.e., all file tags: -->
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{empty DatasetPage.fileTagsFacet ? 'highlightBold' : ''}" value="#{bundle['file.results.filter.all']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                    <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                    <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                </h:outputLink></li>
                            <li role="separator" class="divider"></li>
                            <ui:repeat value="#{DatasetPage.fileTagsFacetLabels}" var="facetLabel">
                                <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                        <h:outputFormat styleClass="#{facetLabel.name == DatasetPage.fileTagsFacet ? 'highlightBold' : ''}" value="#{facetLabel.name} &#40;{0}&#41;">
                                            <f:param value="#{facetLabel.count}"/>
                                        </h:outputFormat>
                                        <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                        <f:param name="version" value="#{DatasetPage.version}"/>
                                        <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                        <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                        <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                        <f:param name="fileTag" value='"#{facetLabel.name}"'/>
                                        <f:param name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                                        <f:param name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                                        <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                        <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                    </h:outputLink></li>
                            </ui:repeat>
                        </ul>
                    </div>
                </div>

                    

                
                <div class="file-sort col-xs-5 text-right #{DatasetPage.indexedVersion ? '' : 'col-xs-offset-7'}">
                    <div class="file-group-by col-xs-7 text-left text-muted small" style="font-weight:normal;" jsf:rendered="#{DatasetPage.allowUserManagementOfOrder()}">
                                    <p:selectBooleanCheckbox id="fps" value="#{DatasetPage.folderPresort}" itemLabel="#{bundle['file.results.presort.folder']}" title="#{bundle['file.results.presort.folder.desc']} rendered='#{DatasetPage.orderByFolder()}'">
                        <p:ajax update="filesTable, messagePanel" process="fps, tps" listener="#{DatasetPage.sort()}"/>
                    </p:selectBooleanCheckbox>
                    <p:selectBooleanCheckbox id="tps" value="#{DatasetPage.tagPresort}" itemLabel="#{bundle['file.results.presort.tag']}" title="#{bundle['file.results.presort.tag.desc']}"  rendered='#{null != DatasetPage.getSortOrder()}'>
                        <p:ajax update="filesTable, messagePanel" process="fps, tps" listener="#{DatasetPage.sort()}"/>
                    </p:selectBooleanCheckbox>
                </div>                
                    <!-- FILES SORT -->
                    <div class="btn-group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-sort"></span> #{bundle['file.results.btn.sort']} <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu pull-right text-left">
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{((empty DatasetPage.fileSortField) or DatasetPage.fileSortField == 'name') and (empty DatasetPage.fileSortOrder) ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.nameAZ']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                    <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                </h:outputLink></li>
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{(DatasetPage.fileSortField == 'name' and DatasetPage.fileSortOrder == 'desc') ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.nameZA']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="name"/>
                                    <f:param name="fileSortOrder" value="desc"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                    <f:param name="folderPresort" value="#{DatasetPage.folderPresort}"/>
                                </h:outputLink></li>
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{(DatasetPage.fileSortField == 'date' and DatasetPage.fileSortOrder == 'desc') ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.newest']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="date"/>
                                    <f:param name="fileSortOrder" value="desc"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                </h:outputLink></li>
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{(DatasetPage.fileSortField == 'date' and (empty DatasetPage.fileSortOrder)) ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.oldest']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="date"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                </h:outputLink></li>
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{DatasetPage.fileSortField == 'size' ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.size']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="size"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                </h:outputLink></li>
                            <li><h:outputLink rel="nofollow" value="/dataset.xhtml">
                                    <h:outputText styleClass="#{DatasetPage.fileSortField == 'type' ? 'highlightBold' : ''}" value="#{bundle['file.results.btn.sort.option.type']}"/>
                                    <f:param name="persistentId" value="#{DatasetPage.persistentId}"/>
                                    <f:param name="version" value="#{DatasetPage.version}"/>
                                    <f:param name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                                    <f:param name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                                    <f:param name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                                    <f:param name="fileSortField" value="type"/>
                                    <f:param name="tagPresort" value="#{DatasetPage.tagPresort}"/>
                                </h:outputLink></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="row" jsf:rendered="#{fileMetadataCount gt 10 and (DatasetPage.selectedFiles.size() gt 0)}">
                <div class="col-xs-12 bg-warning text-left" style="font-weight:normal;padding-top:.5em;">
                    <!-- SELECTION MESSAGE -->
                    <p>
                        <h:outputFormat value="#{bundle['file.numFilesSelected']}">
                            <f:param value="#{DatasetPage.selectedFiles.size()}"/>
                        </h:outputFormat>
                        <ui:fragment rendered="#{DatasetPage.selectedFiles.size() lt fileMetadataCount}">
                            &#160;
                            <p:commandLink action="#{DatasetPage.selectAllFiles}" update="@form">
                                <h:outputFormat value="#{bundle['file.selectAllFiles']}">
                                    <f:param value="#{DatasetPage.fileMetadatasSearch.size()}"/>
                                </h:outputFormat>
                            </p:commandLink>
                        </ui:fragment>
                        &#160;
                        <p:commandLink value="#{bundle['file.clearSelection']}" action="#{DatasetPage.clearSelection}" update="@form"/>
                    </p>
                </div>
            </div>
            <div class="row" jsf:rendered="#{(!DatasetPage.isVersionHasGlobus()) and (DatasetPage.sizeOfSelectedMaxNumeric gt settingsWrapper.zipDownloadLimit)
                                             and DatasetPage.selectedFiles.size() > 1}">
                <div class="col-xs-12 bg-warning text-left" style="font-weight:normal;padding-top:.5em;">
                    <h:outputFormat value="#{bundle['file.zip.download.exceeds.limit']}">
                        <f:param value="#{DatasetPage.sizeOfSelectedMaxAsString}"/>
                        <f:param value="#{DatasetPage.zipDownloadLimitAsString}"/>
                    </h:outputFormat>
                </div>
            </div>
        </f:facet>

        <p:column selectionMode="multiple" class="text-center" ariaHeaderText="#{bundle['file.select.tooltip']}"/>

        <p:column class="col-file-metadata">
            <f:facet name="header">
                <div jsf:id="filesHeaderCount">
                    <!-- Files Count -->
                    <h:outputFormat value="#{DatasetPage.fileMetadatasSearch.size() == 1 ? bundle['file.count.one'] : bundle['file.count']}" styleClass="highlightBold" rendered="#{DatasetPage.fileMetadatasSearch.size() gt 0}">
                        <f:param value="#{(DatasetPage.filePaginatorPage * DatasetPage.rowsPerPage) + 1}"/>
                        <f:param value="#{Math:min((DatasetPage.filePaginatorPage + 1) * DatasetPage.rowsPerPage,DatasetPage.fileMetadatasSearch.size()) }"/>
                        <f:param value="#{DatasetPage.fileMetadatasSearch.size()}"/>
                    </h:outputFormat>
                </div>
            </f:facet>
            <ui:include src="file-info-fragment.xhtml">
                <c:if test="#{fileMetadata != null}">
                    <ui:param name="fileMetadata" value="#{fileMetadata}" />
                </c:if>
            </ui:include>
        </p:column>

        <p:column class="col-file-action button-block text-right" style="width:40%;" ariaHeaderText="#{bundle['file.actionsBlock']}">
            <f:facet name="header">
                <script type="text/javascript">
                    function downloadFiles(url, filelist) {
                        filelist = filelist + ','; //Prevents last file from being dropped on server
                        var form = $('<form></form>').attr('action', url).attr('method', 'post').attr('enctype', 'text/plain');
                        form.append($("<input></input>").attr('type', 'hidden').attr('name', 'fileIds').attr('value', filelist));
                        //Submit and then remove form
                        form.appendTo('body').submit().remove();
                    }
                </script>
                <!-- EDIT -->
                <div style="margin-right:14px;" class="btn-group" jsf:rendered="#{DatasetPage.sessionUserAuthenticated
                                                                                  and DatasetPage.canUpdateDataset() and !widgetWrapper.widgetView and (DatasetPage.fileMetadatasSearch.size() gt 0)}">
                    <button type="button" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown"
                            disabled="#{uploadButtonDisabled}">
                        <span class="glyphicon glyphicon-pencil"/> #{bundle['file.editFiles']} <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu multi-level pull-right text-left">
                        <ui:include src="file-edit-button-fragment.xhtml">
                            <ui:param name="datasetVersion" value="#{DatasetPage.workingVersion}"/>
                            <ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
                            <ui:param name="bean" value="#{DatasetPage}"/>
                            <ui:param name="unrestrictFileAction" value="restrictFiles"/>
                            <ui:param name="refreshTagsPopoupAction" value="refreshTagsPopUp"/>                          
                        </ui:include>  
                    </ul>
                </div>

                <!-- NOTE the disabled="{_datasetPage.lockedFromDownload}" attributes on the 6 batch download buttons below. -->
                <!-- it looks like they were put there in order to disable downloads while the dataset is locked. -->
                <!-- Nobody appears to remember why we would ever want to do that... especially since individual downloads -->
                <!-- are currently allowed on locked datasets. I've been asked to re-enable these download buttons, even -->
                <!-- when the dataset is locked. I didn't want to completely remove the disabled="" attributes, -->
                <!-- since I feel we should figure out/remember why we put that logic in place in the first place... -->
                <!-- so I have replaced them with {false && DatasetPage.lockedFromDownload}. - L.A. Aug. 2018 -->
                <div jsf:id="downloadButtonBlockNormal" class="btn-group" 
                     jsf:rendered="#{(!(empty DatasetPage.workingVersion.fileMetadatas) 
                                     and fileMetadataCount > 1) and DatasetPage.downloadButtonAvailable
                                     and  !(DatasetPage.isVersionHasTabular()||DatasetPage.isVersionHasGlobus())}">
                    <p:commandLink 
                                   styleClass="btn btn-default btn-download"
                                   disabled="#{false and DatasetPage.lockedFromDownload}"
                                   onclick="if (!testFilesSelected()) return false;" 
                                   action="#{DatasetPage.startDownloadSelectedOriginal()}"
                                   update="@form" oncomplete="showPopup(false);">
                        <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                        <f:setPropertyActionListener target="#{DatasetPage.fileMetadataForAction}" value="#{null}"/>
                        <span class="glyphicon glyphicon-download-alt"/> #{bundle.download}
                    </p:commandLink>
                </div>
                <div jsf:id="downloadButtonBlockMultiple" class="btn-group" 
                     jsf:rendered="#{(!(empty DatasetPage.workingVersion.fileMetadatas) 
                                     and fileMetadataCount > 1) and DatasetPage.downloadButtonAvailable
                                     and (DatasetPage.isVersionHasTabular()||DatasetPage.isVersionHasGlobus())}">
                    <button type="button" class="btn btn-default btn-download dropdown-toggle" data-toggle="dropdown">  
                        <span class="glyphicon glyphicon-download-alt"/> #{bundle.download} <span class="caret"></span>
                    </button>
                    <ul jsf:id="downloadDropdownOptions" class="dropdown-menu multi-level pull-right text-left">
                        <li jsf:rendered="#{DatasetPage.canDownloadFiles()}">
                            <p:commandLink
                                           disabled="#{false and DatasetPage.lockedFromDownload}"
                                           update="@form" oncomplete="showPopup(false);"
                                           onclick="if (!testFilesSelected()) return false;" 
                                           actionListener="#{DatasetPage.startDownloadSelectedOriginal()}">
                                <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                                <f:setPropertyActionListener target="#{DatasetPage.fileMetadataForAction}" value="#{null}"/>
                                #{bundle.downloadOriginal}
                            </p:commandLink>
                        </li>
                        <li jsf:rendered="#{DatasetPage.isVersionHasTabular() and DatasetPage.canDownloadFiles()}">
                            <p:commandLink
                                           disabled="#{false and DatasetPage.lockedFromDownload}"
                                           update="@form" oncomplete="showPopup(false);"
                                           onclick="if (!testFilesSelected()) return false;" 
                                           actionListener="#{DatasetPage.startDownloadSelectedArchival()}">
                            <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                            <f:setPropertyActionListener target="#{DatasetPage.fileMetadataForAction}" value="#{null}"/>
                                #{bundle.downloadArchival}
                            </p:commandLink>
                        </li>
                        <li  jsf:rendered="#{DatasetPage.isVersionHasGlobus()}"> 
                            <p:commandLink
                                           disabled="#{false and DatasetPage.lockedFromDownload}"
                                           update="@form" oncomplete="showPopup(true);"
                                           onclick="if (!testFilesSelected()) return false;" 
                                           actionListener="#{DatasetPage.startGlobusTransfer(false, false)}">
                            <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                            <f:setPropertyActionListener target="#{DatasetPage.fileMetadataForAction}" value="#{null}"/>
                                #{bundle['file.globus.transfer']}
                            </p:commandLink>
                        </li>
                    </ul>
                </div>

                <p:commandLink rendered="#{DatasetPage.fileAccessRequestMultiButtonRequired}"
                               styleClass="btn btn-default btn-request"
                               update="@form, @([id$=messagePanel])" 
                               action="#{DatasetPage.validateFilesForRequestAccess()}"
                               disabled="#{DatasetPage.locked or !DatasetPage.fileAccessRequestMultiButtonEnabled}">
                    <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle['file.requestAccess'])}"/>
                    <span class="glyphicon glyphicon-bullhorn"/> #{bundle['file.requestAccess']}
                </p:commandLink>
                <p:commandLink rendered="#{DatasetPage.fileAccessRequestMultiSignUpButtonRequired}"
                               styleClass="btn btn-default btn-request"
                               onclick="PF('accessSignUpLogIn_popup').show()"
                               disabled="#{DatasetPage.locked}">
                    <span class="glyphicon glyphicon-bullhorn"/> #{bundle['file.requestAccess']}
                </p:commandLink>
            </f:facet>

            <!-- FILE LEVEL MSGs -->
            <div class="bg-info text-info text-center margin-bottom-half" jsf:rendered="#{fileMetadata.dataFile.ingestInProgress}">
                <!-- Ingest in progress... -->
                <span class="glyphicon glyphicon-info-sign"/> #{bundle['file.ingestInProgress']}
            </div>

            <div class="bg-info text-info text-center margin-bottom-half" jsf:rendered="#{fileMetadata.dataFile.ingestProblem and DatasetPage.canUpdateDataset()}">
                <!-- Ingest failed -->
                <span class="glyphicon glyphicon-info-sign"/>
                <span> #{bundle['file.ingestFailed.header']}&#160;</span>
                <span>
                    <a tabindex="0" role="button" class="glyphicon glyphicon-question-sign tooltip-icon"
                       data-toggle="popover" data-placement="auto top" data-trigger="focus" data-html="true"
                       data-content="#{DatasetPage.ingestMessage} #{fileMetadata.dataFile.ingestReportMessage}"/>
                </span>
            </div>
            <div class="bg-info text-info text-center margin-bottom-half" jsf:rendered="#{fileMetadata.dataFile.containsActiveFileAccessRequestFromUser(dataverseSession.user)}">
                <!-- Access Requested -->
                <span class="glyphicon glyphicon-info-sign"/>
                <span> #{bundle['file.accessRequested']}&#160;</span>
            </div>
            <div class="label label-info remote-info" jsf:rendered="#{not empty fileMetadata.dataFile.storageIO.remoteStoreName}" 
              title="#{bundle['file.remotelyStored']}">
              <div jsf:rendered="#{not empty fileMetadata.dataFile.storageIO.remoteStoreUrl}">
                  <a href="#{fileMetadata.dataFile.storageIO.remoteStoreUrl.toString()}" target="_blank" rel="noopener">#{fileMetadata.dataFile.storageIO.remoteStoreName}</a>
              </div>
              <span jsf:rendered="#{empty fileMetadata.dataFile.storageIO.remoteStoreUrl}">#{fileMetadata.dataFile.storageIO.remoteStoreName}</span>
            </div>
            <!-- END: FILE LEVEL MSGs -->
                       
            <div class="btn-group" role="group" aria-label="#{bundle['file.actionsBlock']}" jsf:rendered="#{showAccessFileButtonGroup}">
                <!-- Access File - Download, Explore, Compute -->
                <div class="btn-group" jsf:rendered="#{showAccessFileButtonGroup}">
                    
                    <!-- TO-DO FIX RSYNC LOGIC !fileMetadata.dataFile.filePackage or
                                                    fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload -->
                    <ui:fragment rendered="#{DatasetPage.isShowQueryButton(fileMetadata.dataFile)
                                             and fileDownloadHelper.canDownloadFile(fileMetadata)}">                         
                        <a class="btn-preview btn btn-link bootstrap-button-tooltip" title="#{DatasetPage.getQueryToolsForDataFile(fileMetadata.dataFile).get(0).getDisplayNameLang()}"
                            href="#{widgetWrapper.wrapURL('/file.xhtml?'.concat(!empty fileMetadata.dataFile.globalId ? 'persistentId=' : 'fileId=').concat(!empty fileMetadata.dataFile.globalId ? fileMetadata.dataFile.globalId.asString() : fileMetadata.dataFile.id).concat('&amp;version=').concat(fileMetadata.datasetVersion.friendlyVersionNumber)).concat('&amp;toolType=QUERY')}">
                            <img src="#{resource['images/Robot-Icon_2.png']}"  width="32" height="32" /><span class="sr-only">#{bundle.preview} "#{empty(fileMetadata.directoryLabel) ? "":fileMetadata.directoryLabel.concat("/")}#{fileMetadata.label}"</span>
                        </a>                       
                     </ui:fragment>
                                   
                    <ui:fragment rendered="#{DatasetPage.isShowPreviewButton(fileMetadata.dataFile) and fileDownloadHelper.canDownloadFile(fileMetadata)}">
                        <a class="btn-preview btn btn-link bootstrap-button-tooltip" title="#{DatasetPage.getPreviewToolsForDataFile(fileMetadata.dataFile).get(0).getDisplayNameLang()}"
                            href="#{widgetWrapper.wrapURL('/file.xhtml?'.concat(!empty fileMetadata.dataFile.globalId ? 'persistentId=' : 'fileId=').concat(!empty fileMetadata.dataFile.globalId ? fileMetadata.dataFile.globalId.asString() : fileMetadata.dataFile.id).concat('&amp;version=').concat(fileMetadata.datasetVersion.friendlyVersionNumber)).concat('&amp;toolType=PREVIEW')}">
                            <span style="margin-top: 10px;"  class="glyphicon glyphicon-eye-open"/><span class="sr-only">#{bundle.preview} "#{empty(fileMetadata.directoryLabel) ? "":fileMetadata.directoryLabel.concat("/")}#{fileMetadata.label}"</span>
                        </a>
                    </ui:fragment>
                    <a type="button" style="padding:6px 8px;" class="btn-access-file btn btn-link bootstrap-button-tooltip dropdown-toggle" 
                       title="#{bundle['file.accessBtn']}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" tabindex="0">
                        <span style="margin-top: 10px;" class="glyphicon glyphicon-download-alt"/><span class="sr-only">#{bundle['file.accessBtn']}</span><span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu pull-right text-left">
                        <!-- Explore/Download/Request Button Block -->
                        <ui:include src="file-download-button-fragment.xhtml">
                            <ui:param name="fileMetadata" value="#{fileMetadata}"/>
                            <ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
                            <ui:param name="termsPopupRequired" value="#{DatasetPage.termsPopupRequired}"/>
                            <ui:param name="guestbookPopupRequiredAtDownload" value="#{DatasetPage.guestbookPopupRequiredAtDownload}"/>        
                            <ui:param name="guestbookResponse" value="#{DatasetPage.guestbookResponse}"/>
                            <ui:param name="guestbookAndTermsPopupRequired" value="#{DatasetPage.guestbookAndTermsPopupRequired}"/>
                            <ui:param name="guestbookResponseService" value="#{DatasetPage.guestbookResponseService}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                            <ui:param name="lockedFromDownload" value="#{DatasetPage.lockedFromDownload}"/>
                            <ui:param name="exploreTools" value="#{DatasetPage.getExploreToolsForDataFile(fileMetadata.dataFile)}"/>
                            <ui:param name="anonymized" value="#{DatasetPage.anonymizedAccess}"/>
                            <ui:param name="bean" value="#{DatasetPage}"/>
                        </ui:include>
                        <!-- END: Explore/Download/Request Button Block -->

                        <!-- Data Access for Rsync Download -->
                        <ui:fragment rendered="#{fileMetadata.dataFile.filePackage and systemConfig.rsyncDownload 
                                                 and !DatasetPage.workingVersion.getDataset().getStorageIdentifier().startsWith('s3://')}">
                            <li class="dropdown-header">#{bundle['file.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
                            <li>
                                <p:commandLink onclick="PF('rsyncDataAccessPopup').show()">
                                    #{bundle['file.dataFilesTab.dataAccess']}
                                </p:commandLink>
                            </li>
                        </ui:fragment>
                        <!-- END: Data Access for Rsync Download -->
                    </ul>
                </div>

                <!-- File Options -->
                <div class="btn-group" jsf:rendered="#{!widgetWrapper.widgetView 
                                                        and DatasetPage.sessionUserAuthenticated 
                                                        and DatasetPage.canUpdateDataset()
                                                        and hasValidTermsOfAccess
                                                        and DatasetPage.isFileDeleted(fileMetadata.dataFile)}">
                    <a type="button" class="btn-file-options btn btn-link bootstrap-button-tooltip dropdown-toggle #{lockedFromEdits ? 'disabled' : ''}" 
                       disabled="#{lockedFromEdits ? 'disabled' : ''}"
                       title="#{bundle['file.optionsBtn']}" onclick="PF('fileAlreadyDeletedPrevious').show()"
                       tabindex="0">
                        <span class="glyphicon glyphicon-option-vertical"/><span class="sr-only">#{bundle['file.optionsBtn']}</span>
                    </a>                    
                </div>                
                <div class="btn-group" jsf:rendered="#{!widgetWrapper.widgetView 
                                                        and DatasetPage.sessionUserAuthenticated 
                                                        and DatasetPage.canUpdateDataset()
                                                        and hasValidTermsOfAccess
                                                        and !DatasetPage.isFileDeleted(fileMetadata.dataFile)}">
                    <!-- Kebab / Edit / File Options Dropdown -->
                    <a type="button" class="btn-file-options btn btn-link bootstrap-button-tooltip dropdown-toggle #{lockedFromEdits ? 'disabled' : ''}" 
                       disabled="#{lockedFromEdits ? 'disabled' : ''}"
                       title="#{bundle['file.optionsBtn']}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                       tabindex="0">
                        <span class="glyphicon glyphicon-option-vertical"/><span class="sr-only">#{bundle['file.optionsBtn']}</span><span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu multi-level pull-right text-left">
                        <li class="dropdown-header">#{bundle['file.optionsBtn.header.edit']} <span class="glyphicon glyphicon-pencil"/></li>                           
                        <!-- TO-DO NEW FILE-LEVEL EDIT OPTIONS... RENDER LOGIC, LINKS, DISABLED LOGIC -->
                        <!-- Edit Options -->
                        <ui:include src="file-edit-button-fragment.xhtml">
                            <ui:param name="datasetVersion" value="#{DatasetPage.workingVersion}"/>
                            <ui:param name="fileMetadata" value="#{fileMetadata}"/>
                            <ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
                            <ui:param name="isDraftReplacementFile" value="#{false}"/>
                            <ui:param name="hasPackageFile" value="#{fileMetadata.dataFile.filePackage}"/>                                
                            <ui:param name="configureTools" value="#{DatasetPage.getConfigureToolsForDataFile(fileMetadata.dataFile)}"/>
                            <ui:param name="bean" value="#{DatasetPage}"/>
                            <ui:param name="unrestrictFileAction" value="restrictFiles"/>
                        </ui:include>
                    </ul>
                </div>
                <!-- END: File Options -->
            </div>
        </p:column>
    </p:dataTable>

    <!-- Files Tree -->
    <p:tree id="filesTree" style="width:100%;"
            rendered="#{DatasetPage.fileDisplayTree}"
            widgetVar="filesTree"
            value="#{DatasetPage.filesTreeRoot}"
            var="node">
        <p:treeNode expandedIcon="ui-icon ui-icon-folder-open" collapsedIcon="ui-icon ui-icon-folder-collapsed">
            <!-- For a folder, the node payload is just its name as a String object, that we display here: -->
            <h:outputText value="#{node}"/>
        </p:treeNode>
        <p:treeNode type="customFileNode">
            <!-- For a file, the payload data ("node") is the corresponding FileMetadata object: -->
            <span class="icon-#{dataFileServiceBean.getFileThumbnailClass(node.dataFile)} text-muted"/>
            <!-- conditional render in file page links, if file has global id, use that; if not, we use database id -->
            <a href="#{widgetWrapper.wrapURL('/file.xhtml?'.concat(!empty node.dataFile.globalId ? 'persistentId=' : 'fileId=').concat(!empty node.dataFile.globalId ? node.dataFile.globalId.asString() : node.dataFile.id).concat('&amp;version=').concat(DatasetPage.workingVersion.friendlyVersionNumber))}">
                #{node.label}
            </a>
            <span class="text-muted">(#{node.dataFile.friendlySize})</span>
        </p:treeNode>
    </p:tree>      
</ui:composition>
